<?php defined('SYSPATH') or die('No direct script access.');

class Controller_User_Signup extends Controller_DefaultTemplate{

public function action_index()
{
}

public function action_regSave()
{
	if ($_POST)
    {
		$user = ORM::factory('user');
		$user->values(array(
			'email' => arr::get($_POST, 'email'),
		    'password' => arr::get($_POST, 'password'),
		    'password_confirm' => arr::get($_POST, 'password_confirm'),
		));
		$user->save();
		$user->add('roles', ORM::factory('role')->where('name', '=', 'login')->find());

		Auth::instance()->login(arr::get($_POST, 'email'), arr::get($_POST, 'password'));

		$this->request->redirect('blogger/dashboard');
	}
}

/**
* Initialize properties before running the controller methods (actions),
* so they are available to our action.
*/
public function before()
{
	// Run anything that need ot run before this.
	parent::before();

	if (Auth::instance()->logged_in())
	{
		$this->request->redirect('');
	}

	$this->template->content = View::factory('/user/signup');
}

}

